package com.liu.netty.service;

import com.liu.netty.dao.DriverDao;
import com.liu.netty.entity.Driver;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import util.IdWorker;

import javax.transaction.Transactional;

@Service
@Slf4j
@Transactional
public class DriverService {

    @Autowired
    private DriverDao driverDao;

    @Autowired
    private IdWorker idWorker;


    public void addDriver(Driver driver) {

        driver.setId(idWorker.nextId()+"");
        driverDao.save(driver);
    }

    public Driver selectById(String id) {

         return driverDao.findById(id).get();

    }
}
